//
//  BMSOfficialHolidayModel.m
//  WDBMS
//
//  Created by YeJary on 2025/5/12.
//

#import "BMSOfficialHolidayModel.h"

@implementation BMSOfficialHolidayModel

+ (instancetype)modelWithRawArray:(NSArray *)array {
    BMSOfficialHolidayModel *model = [[BMSOfficialHolidayModel alloc] init];
    NSMutableArray *valid = [NSMutableArray array];
    for (id obj in array) {
        if ([obj isKindOfClass:[NSString class]] && ((NSString *)obj).length == 8) {
            [valid addObject:obj];
        }
    }
    model.holidayList = valid;
    return model;
}

- (BOOL)isTodayHoliday {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"yyyyMMdd";
    NSString *today = [formatter stringFromDate:[NSDate date]];
    return [self.holidayList containsObject:today];
}

- (BOOL)isHoliday:(NSString *)dayString {
    if (!dayString || dayString.length != 8) return NO;
    return [self.holidayList containsObject:dayString];
}

@end

